Chart for WPF and Silverlight > Chart Features > Axis > Annotation > Creating an Annotation Template |
To create a custom annotation using the AnnoTemplate property, use the following XAML markup or C# code:
XAML |
Copy Code
|
---|---|
<c1chart:ChartView.AxisX> <c1chart:Axis> <c1chart:Axis.Resources > <local:ColorConverter x:Key="clrcnv" /> </c1chart:Axis.Resources> <c1chart:Axis.AnnoTemplate> <DataTemplate> <TextBlock Width="25" TextAlignment="Center" Text="{Binding Path=Value}" Foreground="{Binding Converter={StaticResource clrcnv}}"/> </DataTemplate> </c1chart:Axis.AnnoTemplate> </c1chart:Axis> </c1chart:ChartView.AxisX> |
C# |
Copy Code
|
---|---|
public class ColorConverter : IValueConverter { int cnt = 0; public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { //DataPoint dpt = (DataPoint)value; // alternate the brushes return cnt++ % 2 == 0 ? Brushes.Blue : Brushes.Red; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return null; } } |